/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2021-01-08
*/
package com.rzico.market.service;

import com.rzico.base.BaseMapper;
import com.rzico.base.impl.BaseServiceImpl;
import com.rzico.market.entity.PhoneProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.rzico.market.mapper.PhoneProductMapper;

import java.util.HashMap;
import java.util.Map;

/**
 * <pre>
 * 豆讯话费产品档案业务类
 * </pre>
 *
 * @author Rzico Boot
 * @version 1.0
 */
@Service
public class PhoneProductService extends BaseServiceImpl<PhoneProduct, String> {

    @Autowired
    private PhoneProductMapper phoneProductMapper;

    @Override
    public BaseMapper<PhoneProduct, String> getMapper() {
        return phoneProductMapper;
    }

    public Map<String, Object> checkStock(Long id){
        Map<String,Object> result = new HashMap<String, Object>();
        PhoneProduct phoneProduct = selectByPrimaryKey(id);
        if (0 < phoneProduct.getStock()) {
            result.put("check_result", "success");
        } else {
            result.put("check_result", "fail");
        }

        return result;
    }

    /**
     * 添加库存
     * @param params
     * @return
     */
    public Integer addStock(Map<String, Object> params){
        return phoneProductMapper.addStock(params);
    }

    /**
     * 减少库存
     * @param params
     * @return
     */
    public Integer decStock(Map<String, Object> params){
        return phoneProductMapper.decStock(params);
    }


}
